//
//  OMTImagePickerController.h
//  OMTImagePicker
//
//  Created by yizhaorong on 2017/11/15.
//

#import <UIKit/UIKit.h>
#import "OMTImagePickerBuilder.h"
#import "OMTAlbumManager.h"

// 图片宽度
FOUNDATION_EXTERN NSString *const OMTImagePickerControllerPhotoWidthKey;
// 图片高度
FOUNDATION_EXTERN NSString *const OMTImagePickerControllerPhotoHeightKey;
// 图片文件大小
FOUNDATION_EXTERN NSString *const OMTImagePickerControllerPhotoFileSizeKey;
// 视频时长
FOUNDATION_EXTERN NSString *const OMTImagePickerControllerVideoDurationKey;
// 图片来源
FOUNDATION_EXTERN NSString *const OMTImagePickerControllerPhotoSourceKey;
// URL
FOUNDATION_EXTERN NSString *const OMTImagePickerControllerAssetURLKey;
// 资源类型
FOUNDATION_EXTERN NSString *const OMTImagePickerControllerAssetTypeKey;


typedef NS_ENUM(NSUInteger, OMTImagePickerPhotoSource) {
    OMTImagePickerPhotoSourceGallery = 0,           ///< 相册
    OMTImagePickerPhotoSourceCamera = 1,          ///< 相机
};

typedef NS_ENUM(NSUInteger, OMTImagePickerAssetType) {
    OMTImagePickerAssetTypeImage = 0,
    OMTImagePickerAssetTypeGIF = 1,
    OMTImagePickerAssetTypeVideo = 2
};

typedef NS_ENUM(NSUInteger, OMTImagePickerSelectIllegalType) {
    OMTImagePickerSelectIllegalTypeNone = 0,        ///< 合法
    OMTImagePickerSelectIllegalTypePhoto = 1,       ///< 选择图片非法
    OMTImagePickerSelectIllegalTypeVideo            ///< 选择视频非法
};

@class OMTImagePickerController;

@protocol OMTImagePickerControllerDelegate <NSObject, UINavigationControllerDelegate>

@optional

/**
 完成了照片选择

 @param image 图片
 @param imageData Data
 */
- (void)imagePickerController:(OMTImagePickerController *)picker didFinishPickingImage:(UIImage *)image
                    imageData:(NSData *)imageData;


/**
 完成了照片选择

 @param images 图片列表
 @param imageDatas Datas
 */
- (void)imagePickerController:(OMTImagePickerController *)picker didFinishPickingImages:(NSArray<UIImage *> *)images
                    imageDatas:(NSArray<NSData *> *)imageDatas;


/**
 允许不选择图片时，跳过

 @param picker 选择器
 */
- (void)imagePickerControllerDidSkip:(OMTImagePickerController *)picker;

/**
 取消
 */
- (void)imagePickerControllerDidCancel:(OMTImagePickerController *)picker;

@end


@interface OMTImagePickerController : UINavigationController
// 代理
@property (nonatomic, weak) id<OMTImagePickerControllerDelegate, UINavigationControllerDelegate> delegate;
// 配置
@property (nonatomic, strong, readonly) OMTImagePickerBuilder *builder;
// 相册管理器
@property (nonatomic, strong) OMTAlbumManager *albumManager;
// 选中的图片
@property (nonatomic, strong) NSMutableArray *selectedPhotos;
// 选择完成回调
@property (nonatomic, copy) void (^imagePickerControllerDidFinishHandle)(OMTImagePickerController *picker, NSArray<UIImage *> *images, NSArray<NSData *> *imageDatas, NSArray<NSDictionary *> *infos);
// 取消选择
@property (nonatomic, copy) void (^imagePickerControllerDidCancelHandle)(void);
// 选择错误回调
@property (nonatomic, copy) void (^imagePickerControllerSelectIllegalHandle)(OMTImagePickerController *picker, OMTAsset *asset, OMTImagePickerSelectIllegalType type);
// 点击了录制视频
@property (nonatomic, copy) void (^imagePickerControllerStartRecordVideoHandle)(OMTImagePickerController *picker);

- (instancetype)init NS_UNAVAILABLE;

+ (instancetype)new NS_UNAVAILABLE;

/**
 通过配置初始化

 @param builder 配置器
 @return 实例
 */
- (instancetype)initWithBuilder:(void (^)(OMTImagePickerBuilder *builder))builder;

@end
